
#include "interrupciones.h"

// Timer Interrupt
// This function is an interrupt service routine for Timer 0. It should never
// be called by a C or assembly function. It will be executed automatically
// when Timer 0 overflows.
// "interrupt 1" tells the compiler to look for this ISR at address 000Bh
// "using 1" tells the compiler to use register bank 1
void timer0 (void) interrupt 1 using 1
{
	// Stop Timer 0, adjust the Timer 0 counter so that we get another
	// in 10ms, and restart the timer.
	TR0 = 0; // stop timer
	TL0 = TL0 + (TIMER0_COUNT & 0x00FF);
	TH0 = TH0 + (TIMER0_COUNT >> 8);
	TR0 = 1; // start Timer 0
	// Increment the timer tick. This interrupt should occur approximately every 10ms. So,
	//the resolution of the timer will be 100Hz not including interrupt latency.
	timer0_tick++;	
}

// Timer Interrupt
// This function is an interrupt service routine for Timer 1. It should never
// be called by a C or assembly function. It will be executed automatically
// when Timer 1 overflows.
// "interrupt 1" tells the compiler to look for this ISR at address 000Bh
// "using 1" tells the compiler to use register bank 1
void timer1 (void) interrupt 3 using 1
{
	// Stop Timer 0, adjust the Timer 0 counter so that we get another
	// in 10ms, and restart the timer.
	TR1 = 0; // stop timer
	TL1 = TL1 + (TIMER1_COUNT & 0x00FF);
	TH1 = TH1 + (TIMER1_COUNT >> 8);
	TR1 = 1; // start Timer 1
	// Increment the timer tick. This interrupt should occur approximately every 10ms. So,
	//the resolution of the timer will be 100Hz not including interrupt latency.
	timer1_tick++;
	timer1_delay_disparo++;
	timer1_tiempo_on_disparo++;
	timer1_tiempo_on_disparo_retrasado++;	
}